<template>
  <div class="listViewTop">
    <img class="bg" :src="playlist.coverImgUrl" alt="" />
    <!-- 头部 -->
    <div class="listViewTopNav">
      <!-- 左箭头 -->
      <div class="back">
        <svg class="icon" aria-hidden="true" @click="$router.back()">
          <use xlink:href="#icon-zuojiantou"></use>
        </svg>
        <div class="title">歌单</div>
      </div>
      <div class="right">
        <!-- 搜索 -->
        <svg class="icon search" aria-hidden="true">
          <use xlink:href="#icon-sousuo"></use>
        </svg>
        <!-- 更多 -->
        <svg class="icon more" aria-hidden="true">
          <use xlink:href="#icon-gengduo"></use>
        </svg>
      </div>
    </div>
    <!-- 封面与歌单描述 -->
    <div class="content">
      <div class="contentLeft">
        <img v-lazy="playlist.coverImgUrl" @click="show = true" />
        <span class="num">▷{{ formatNumber(playlist.playCount) }}</span>
      </div>
      <div class="contentRight">
        <h4>{{ playlist.name }}</h4>
        <!-- 作者 -->
        <div class="author">
          <img v-lazy="playlist.creator.avatarUrl" class="header">
          <span>{{playlist.creator.nickname}}</span>
        </div>
        <!-- 歌单介绍 -->
          <div class="description">
            {{playlist.description}}
          </div>
      </div>
    </div>
    <!-- 中间图标入口 -->
    <div class="iconList">
      <div class="icon-item">
        <svg class="icon " aria-hidden="true" style="width: 0.4rem;">
          <use xlink:href="#icon-pinglun1"></use>
        </svg>
        <span>{{playlist.commentCount}}</span>
      </div>
      <div class="icon-item">
        <svg class="icon " aria-hidden="true">
          <use xlink:href="#icon-fenxiang"></use>
        </svg>
        <span>{{playlist.shareCount}}</span>
      </div>
      <div class="icon-item">
        <svg class="icon " aria-hidden="true">
          <use xlink:href="#icon-xiazai"></use>
        </svg>
        <span>下载</span>
      </div>
      <div class="icon-item">
        <svg class="icon " aria-hidden="true">
          <use xlink:href="#icon-duoxuankuang"></use>
        </svg>
        <span>多选</span>
      </div>
    </div>
  </div>


  <!-- 歌单介绍遮罩层 -->
  <van-config-provider :theme-vars="themeVars">
    <van-overlay :show="show" @click="show = false" style="overflow: scroll;">
      <!-- 背景虚化图   -->
      <img :src="playlist.coverImgUrl" style="filter: blur(80px); object-fit: cover; height: 100%; width: 100%; ">
      <!-- 头像和歌单名字、叉叉关闭按钮-->
      <div class="tgx" style="width: 7.5rem;height: 43.3%;text-align:center; position: absolute; top: 0.2rem; left: 0;">
        <svg class="icon search" aria-hidden="true" style="fill: #fff;position: fixed; top: 0.35rem; right: 0.4rem;">
          <use xlink:href="#icon-chacha"></use>
        </svg>
        <img :src="playlist.coverImgUrl" style="width: 3.8rem; border-radius: 0.3rem;margin: 0.7rem 1.8rem 0.3rem 1.8rem;">
        <span style="color:#fff; padding-top: 1rem; font-size: 14px;" >{{playlist.name}}</span>
      </div>
      <!-- 标签和歌单描述 -->
      <div style="position: absolute; top: 6.3rem; left: 0.5rem; color: #fff; margin-right: 0.5rem;" >
        <div>
          <span style="font-size: 0.3rem;">标签: </span>
          <span style="margin-left: 0.2rem; font-size: 0.1rem; padding: 0.05rem 0.15rem;border-radius: 0.2rem;background-color: rgb(255, 255, 255,0.3);"
          v-for="(item) in props.playlist.tags" :key="item.id"
          >{{item}}</span>          
        </div>
        <div style="margin-top: 0.35rem;font-size: 0.27rem;">{{playlist.description}}</div>
      </div>
      <!-- 保存图片 -->
      <div style="font-size: 0.26rem;position:fixed;right:2.9rem;top: 12.2rem;border:1px solid #eee; padding: 0.08rem 0.25rem;border-radius: 0.3rem;">
          <a :href="playlist.coverImgUrl" :download="playlist.coverImgUrl" style="color:#fff;">保存图片</a>
      </div>
    </van-overlay>
  </van-config-provider>

</template>

<script setup>
import { formatNumber } from '@/util/formatNumber.js'
import { reactive, ref } from 'vue'

const props = defineProps({
  playlist: {
    type: Object,
    default: {}
  }
})

// 遮罩层的显示与隐藏
const show = ref(false)
// 歌单详情遮罩层的默认虚化背景
const themeVars = {
  overlayBackgroundColor: '#fff'
}
</script>



<style lang="less" scoped>
.listViewTop {
  width: 7.5rem;
  padding: 0 0.4rem;
  // height: 6rem;
  .bg {
    position: fixed;
    left: 0;
    top: 0;
    width: 7.5rem;
    height: auto;
    z-index: -1;
    // 滤镜
    filter: blur(40px);
  }
  .listViewTopNav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 1.2rem;
    font-size: 0.33rem;
    .icon {
      width: 0.5rem;
      height: 0.5rem;
    }
    .title {
      margin-left: 0.4rem;
    }
    .search {
      margin-right: 0.5rem;
    }
    .more {
      margin-right: -0.2rem;
    }
  }
  .back,
  .right {
    display: flex;
    color: #fff;
  }
  .content {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    .contentLeft {
      position: relative;
      img {
        width: 2.5rem;
        height: 2.4rem;
        border-radius: 0.1rem;
      }
      span {
        color: #fff;
        position: absolute;
        right: 0.1rem;
        top: 0.1rem;
        font-size: 0.2rem;
        opacity: 0.9;
      }
    }
    .contentRight {
      margin-top: 0.1rem;
      width: 3.8rem;
      h4 {
        color: #fff;
        font-size: 0.28rem;
      }
      .author{
        display: flex;
        align-items: center;
        margin: 0.18rem 0;
        img.header{
          width: 0.6rem;
          height: 0.6rem;
          border-radius: 0.3rem;
          margin-right: 0.1rem;
        } 
        span {
          color: rgba(231, 231, 231, 0.986);
          font-size: 0.24rem;
        }
      } 
      .description {
        font-size: 0.23rem;
        color: #eee;
        // 显示两行文字
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
    }
  }
  .iconList {
    display: flex;
    justify-content: space-around;
    .icon-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      .icon {
        width: 0.35rem;
        height: 0.4rem;
        fill: #fff;
      }
      span {
        padding-top: 0.1rem;
        font-size: 0.1rem;
        color: #fff;
      }
    }
  }
}



// 遮罩层边框线渐变
.tgx {
  border-bottom: 1px solid;
  border-image: linear-gradient(90deg, rgba(238, 0, 0, 0) 0%, #feffff66 60%, rgba(255, 255, 255, 0) 93%) 2 2 2 2;
}

</style>